package com.yuan.aicodemother.core.save;

import com.yuan.aicodemother.ai.model.CodeGenTypeEnum;
import com.yuan.aicodemother.ai.model.HtmlCodeResult;
import com.yuan.aicodemother.exception.BusinessException;
import com.yuan.aicodemother.exception.ErrorCode;

public class HtmlCodeFileSaverTemplate extends CodeFileSaverTemplate<HtmlCodeResult>{

    @Override
    protected void saveFiles(HtmlCodeResult result, String baseDirPath) {
        writeToFile(baseDirPath,"index.html",result.getHtmlCode());
    }

    protected void validateInput(HtmlCodeResult result) {
        if (result == null) {
            if (result.getHtmlCode() == null){
                throw new BusinessException(ErrorCode.SYSTEM_ERROR, "HTML代码不能为空");
            }
        }
    }

    @Override
    protected CodeGenTypeEnum getCodeType() {
        return CodeGenTypeEnum.HTML;
    }


}
